﻿@model IEnumerable<LanDBom.Models.libray>

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Genertals.cshtml";
}

<h2>工艺库查看</h2>
<form class="row padtop col-12" action="#" method="post">
    <fieldset class="boun">
        <legend class="len">查询条件</legend>
        <div class="row">
            <p class="col-3">
                @Html.Label(" 工艺编号：")
                @Html.TextBox("shen")
            </p>
            <p class="col-3">
                @Html.Label("工艺名称：")
                @Html.TextBox("ming")
            </p>
            <p class="col-3">
                @Html.Label("工艺分类：")
                @Html.TextBox("shi")
            </p>
            <p class="col-3">
                <input type="button" value="查询" name="cha" class="col-3" />
            </p>
        </div>

    </fieldset>
</form>
<p>
    @Html.ActionLink("添加工艺", "Create")
    @Html.ActionLink("添加工艺分类", "Create")
</p>
<table class="tab table">
    <thead class="thead-light">
        <tr style="text-align-last:center;">
            <th>
                @Html.Label("编号")
            </th>
            <th>
                @Html.Label("工艺名")
            </th>
            <th>
                @Html.Label("单位")
            </th>
            <th>
                @Html.Label("价格")
            </th>
            <th>
                @Html.Label("损耗")
            </th>
            <th>
                @Html.Label("分类")
            </th>
            <th></th>
        </tr>
    </thead>

    <tbody style="height:450px" class="gun" id="BUtain">
        @foreach (var item in Model)
        {
            <tr style="text-align-last:center;">
                <td>
                    @Html.DisplayFor(modelItem => item.LB_bai)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.LB_fne)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.LB_dan)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.LB_jia)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.LB_shun)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Steelmaking.ST_fne)
                </td>
                <td>
                    @Html.ActionLink("修改", "Edit", new { id = item.LB_ID }) |
                    @Html.ActionLink("删除", "Delete", new { id = item.LB_ID })
                </td>
            </tr>
        }
    </tbody>


</table>
@section scripts{
    <script src="~/Scripts/jquery-3.4.1.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script>
        //页面加载
        $(function () {
            $("#ULen").addClass("Ulte");
        })
        $(function () {
            
            //查看
            $('input[name="cha"]').click(function () {
                var shen = $("#shen").val()
                var shi = $("#shi").val()
                var ming = $("#ming").val()
                $.ajax({
                    url: '/librays/Index',
                    type: 'POST',
                    data: { "LB_bai": shen, "LB_fne": ming, "ST_fne": shi, "stantes": 2 },
                    success: function (date) {
                        createRow(date);
                    },
                    error: function (date) {
                        alert("错误 请重试！")
                    }
                })
            })
            function createRow(date) {
                $("#BUtain tr").remove();
                $.each(date, function (i, item) {
                    var $tr = (`
                        <tr>
                            <td>${item.LB_ID}</td>
                            <td>${item.LB_bai}</td>
                            <td>${item.LB_fne}</td>
                            <td>${item.ST_fne}</td>
                            <td style="display:none">${item.ST_ID}</td>
                            <td>${item.LB_dan}</td>
                            <td>${item.LB_jia}</td>
                            <td>${item.LB_shun} </td>
                        </tr>
                        `);
                    $("#BUtain").append($tr);
                })
            }
           

        })

    </script>
}